Communications 102

I will say "Hello World" in bold print just below this line by calling a JavaScript function.

Discussion

In this second program, you see how to call a JavaScript function from HTML. This script calls the function hello_world without any parameters. This function is declared in the HTML head, as are most JavaScript functions. This helps separate JavaScript functionality from document content and makes your HTML easier to understand and maintain.

The hello_world() function

function hello_world(){
document.write("<b>Hello World!</b><p>")
}

The calling HTML script

<SCRIPT LANGUAGE="JavaScript">
hello_world()
</SCRIPT>
Copyright ©1998 by Charles River Media, All Rights Reserved